package com.hmall.order.web;

import com.hmall.common.dto.Address;
import com.hmall.order.pojo.Order;
import com.hmall.order.service.IAddressService;
import com.hmall.order.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Saint.Martine
 * @since 2022/12/11 20:45
 */
@Slf4j
@RestController
@RequestMapping("address")
public class AddressController {
    @Autowired
    private IAddressService iAddressService;

    //根据地址id 查询地址内容
    @GetMapping("addressId}")
    public Address findAddressById(@PathVariable("addressId") Long id) {
        return iAddressService.getById(id);
    }


    //用户id查询地址列表，是列表！
    @GetMapping("/uid/{userId}")
    public List<Address> findAddressByUserId(@PathVariable("userId") Long userId) {
        return iAddressService.query().eq("usr_id", userId).list();
    }
}
